const {insertHistory} = require('../db.js')

const puppeteer = require('puppeteer')
const detail = require('../detail.js')

async function run() {
    const browser = await puppeteer.launch()
    const page = await browser.newPage()
    let info = await detail(page, '127034')
    //console.log(JSON.stringify(info, null, '  '))
    let result = await insertHistory(info.convertible.bondcode, info.history)
    await browser.close()
    console.log(JSON.stringify(result, null, '  '))
    process.exit(0)
}

run().catch(err => {
    console.log(err)
    process.exit(1)
})
